package com.library.controllers;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletPreferences;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.bind.annotation.ActionMapping;
import org.springframework.web.portlet.bind.annotation.RenderMapping;

import com.liferay.portal.kernel.util.ParamUtil;

@Controller(value = "EditController")  
@RequestMapping("EDIT")
public class EditController {
	 @RenderMapping 
	    public String handleRenderRequest(RenderRequest request,RenderResponse response,Model model){ 
	      
	     return "edit"; 
	    }
	     @ActionMapping(params = "action=setCapacity")
	        public void setCapacity(ActionRequest actionRequest,
	                ActionResponse actionResponse) throws IOException, PortletException {
	            int maxCapacity = ParamUtil.getInteger(actionRequest,
	                    "library_capacity");
	            PortletPreferences preferences = actionRequest.getPreferences();
	            preferences.setValue("library_capacity", String.valueOf(maxCapacity));
	            preferences.store();
	        }
}
